"use strict";
/**
 * @ Author: Yoann Meclot. MSay2
 * @ Created on: 2020-08-30 18:31:28
 * @ Modified on: 2021-06-16 15:18:22
 *
 * @version 1.3
 */
/**
 * Copyright (c) 2020-2021 MSay2 (Yoann Meclot) - @msay2/tspoet
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.TSConstant = void 0;
const ArrayList_js_1 = require("../util/list/ArrayList.js");
const LinkedMap_js_1 = require("../util/list/LinkedMap.js");
const Utils_js_1 = require("../util/Utils.js");
/**
 * TSConstant object allows you to build constants for enumerations.
 *
 * @class `TSConstant`
 * @version 1.2
 */
class TSConstant {
    constructor(builder) {
        this.mConstants = builder.mConstants;
        this.mDocs = builder.mDocs;
    }
    /**
     * Build constant.
     *
     * @param name The name of the constant.
     * @param value The value of the constant.
     * @throws {TSPoetException} Check if the name is undefined or null.
     * @throws {TSPoetException} Check if the value is undefined or null.
     * @type {TSConstant.Builder}
     * @since 1.0
     */
    static constantBuilder(name, value) {
        return new TSConstant.Builder(name, value);
    }
    emit(codeWriter) {
        codeWriter.emitConstant(this);
        return codeWriter;
    }
}
exports.TSConstant = TSConstant;
TSConstant.Builder = class Builder {
    constructor(name, value) {
        this.mConstants = new LinkedMap_js_1.LinkedMap();
        this.mDocs = new ArrayList_js_1.ArrayList();
        this.mConstants.add(Utils_js_1.Preconditions.checkNotNull(name, "constant name", "name"), Utils_js_1.Preconditions.checkNotNull(value, "constant value", "value"));
    }
    /**
     * Add documentation.
     *
     * @param arg Your comment.
     * @throws {TSPoetException} Check if the arg is undefined or null.
     * @type {TSConstant.Builder}
     * @since 1.1
     */
    addDoc(arg) {
        this.mDocs.add(Utils_js_1.Preconditions.checkNotNull(arg, "constant documentation", "string argument"));
        return this;
    }
    /**
     * Build constant.
     *
     * @type {TSConstant}
     * @since 1.0
     */
    build() {
        return new TSConstant(this);
    }
};
//# sourceMappingURL=TSConstant.js.map